/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kodi.view;

import com.opensymphony.xwork2.ActionSupport;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import kodi.controller.LoginManager;
import kodi.model.User;
import kodi.model.UserRights.Task;


public class LoginAction extends ActionSupport {

    private User login;
    private LoginManager loginController;
    private Set<Task> taskSet  = new HashSet();
    private User result;
    public LoginAction() {
        loginController = new LoginManager();
    }

    public String execute() throws Exception {
        
        try {
           result = loginController.verifyLogin(getLogin());
           //loginController.retrieveTasks(result.getUser_id());
           taskSet = result.getTasklist();
       
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result != null) {
            return INPUT;
        }
        return ERROR;
    }

    public User getLogin() {
        return login;
    }

    public void setLogin(User login) {
        this.login = login;
    }

    /**
     * @return the result
     */
    public User getResult() {
        return result;
    }

    /**
     * @param result the result to set
     */
    public void setResult(User result) {
        this.result = result;
    }

    /**
     * @return the taskSet
     */
    public Set<Task> getTaskSet() {
        return taskSet;
    }

    /**
     * @param taskSet the taskSet to set
     */
    public void setTaskSet(Set<Task> taskSet) {
        this.taskSet = taskSet;
    }
}
